import { ApiResponse } from '@/types/api';
import { post, RequestConfig, uploadFile } from '@/utils/request';

/**
 * 通用API
 */
export class BaseAPI {
  /**
   * 上传文件
   * @param file 要上传的文件对象
   * @param filename 文件名字段名，默认为'file'
   * @param extraData 额外的表单数据
   * @param config 请求配置
   * @returns Promise<ApiResponse<T>>
   */
  static async uploadFile<T = any>(
    file: File,
    filename: string = 'file',
    extraData?: Record<string, any>,
    config?: RequestConfig
  ): Promise<ApiResponse<T>> {
    return uploadFile('/files/upload', file, filename, extraData, config);
  }
}
